package com.carlinfo.stu_ques.demo.dao.impl;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;

import com.carlinfo.stu_ques.common.dao.impl.BaseDaoimpl;
import com.carlinfo.stu_ques.common.util.FileUtil;
import com.carlinfo.stu_ques.demo.dao.IDynastyDao;
import com.carlinfo.stu_ques.demo.pojo.Dynasty;

public class DynastyDaoImpl extends BaseDaoimpl<Dynasty> implements IDynastyDao 
{
	File file = new File(parentFile, "a.dat");
	public DynastyDaoImpl()
	{
		readFile(file);
	}
	
	
	@Override
	public int savaOneDao(Dynasty dynasty)
	{
		/* ID 要不重复 */
		dynasty.setId(this.count);
		tempId = dynasty.getId();
		tempId = super.savaOneDao(dynasty);
		writeFile(file);
		return dynasty.getId();
	}

	 

	@Override
	public void deleteOneDao(Dynasty dynasty)
	{
		tempId = dynasty.getId();
		super.deleteOneDao(dynasty);
		writeFile(file);
	}

	@Override
	public void updateOneDao(Dynasty dynasty)
	{
		tempId = dynasty.getId();
		super.updateOneDao(dynasty);
		writeFile(file);
	}

}
